package org.tabcap.gui.menu;

import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;

import org.tabcap.TCInstance;

public class TCButtonToolbar extends JToolBar
{
	private static final long serialVersionUID = 5150358180976576649L;
	
	public TCButtonToolbar(TCInstance manager)
	{
		super("Toolbar");
		setFloatable(false);

		addButton("New", manager.images().getIcon("New"), manager.newAction());
		addButton("Open", manager.images().getIcon("Open"), manager.openAction());
		addButton("Save", manager.images().getIcon("Save"), manager.saveAction());
		addSeparator();
		addButton("Cut", manager.images().getIcon("Cut"), manager.cutAction());
		addButton("Copy", manager.images().getIcon("Copy"), manager.copyAction());
		addButton("Paste", manager.images().getIcon("Paste"), manager.pasteAction());
		addSeparator();
		addButton("Run", manager.images().getIcon("Run"), manager.runAction());
		addButton("Compile", manager.images().getIcon("Compile"), manager.compileAction());
		addSeparator();
		addButton("Help", manager.images().getIcon("Help"), manager.helpAction());
	}
	
	protected void addButton(String name, ImageIcon icon, ActionListener action)
	{
		JButton button = new JButton(icon);
		button.setName(name);
		button.setToolTipText(name);
		button.setActionCommand(name);
		if(action != null)
			button.addActionListener(action);
		add(button);
	}
}